package org.example.constant;

import java.util.HashMap;
import java.util.Map;

//学籍状态枚举
public enum EnrollmentStatus {
    ENROLLED("在读"),
    SUSPENDED("休学"),
    GRADUATED("毕业");

    //描述学籍状态
    private String description;

    private EnrollmentStatus(String description) {
        this.description = description;
    }

    //将来构造key=velue的键值对存入map，key代表学籍中文状态，value代表对应的常量
    private static Map<String, EnrollmentStatus> map = new HashMap<String, EnrollmentStatus>();
    //利用静态代码块，将map进行初始化，随着枚举类的加载而执行
    static {
        for (EnrollmentStatus es : EnrollmentStatus.values()) {
            map.put(es.toString(), es);
        }
    }

    
    public static EnrollmentStatus getEnumByDesc(String desc) {
        return map.get(desc);
    }

    @Override
    public String toString() {
        return description;
    }

}

